/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "SYS_USER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SysUser.findAll", query = "SELECT s FROM SysUser s"),
    @NamedQuery(name = "SysUser.findBySysUserId", query = "SELECT s FROM SysUser s WHERE s.sysUserId = :sysUserId"),
    @NamedQuery(name = "SysUser.findByLogin", query = "SELECT s FROM SysUser s WHERE s.login = :login"),
    @NamedQuery(name = "SysUser.findByPassword", query = "SELECT s FROM SysUser s WHERE s.password = :password"),
    @NamedQuery(name = "SysUser.findByFirstname", query = "SELECT s FROM SysUser s WHERE s.firstname = :firstname"),
    @NamedQuery(name = "SysUser.findByLastname", query = "SELECT s FROM SysUser s WHERE s.lastname = :lastname"),
    @NamedQuery(name = "SysUser.findByAge", query = "SELECT s FROM SysUser s WHERE s.age = :age"),
    @NamedQuery(name = "SysUser.findByCity", query = "SELECT s FROM SysUser s WHERE s.city = :city"),
    @NamedQuery(name = "SysUser.findByInfo", query = "SELECT s FROM SysUser s WHERE s.info = :info"),
    @NamedQuery(name = "SysUser.findByEMail", query = "SELECT s FROM SysUser s WHERE s.eMail = :eMail"),
    @NamedQuery(name = "SysUser.findByContactInformation", query = "SELECT s FROM SysUser s WHERE s.contactInformation = :contactInformation"),
    @NamedQuery(name = "SysUser.findByLinkOnSource", query = "SELECT s FROM SysUser s WHERE s.linkOnSource = :linkOnSource"),
    @NamedQuery(name = "SysUser.findByDescription", query = "SELECT s FROM SysUser s WHERE s.description = :description"),
    @NamedQuery(name = "SysUser.authorize", query = "SELECT s FROM SysUser s WHERE s.login = :login and s.password = :password")
})
public class SysUser  extends AEntityContentProvider<SysUser> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
    //@SequenceGenerator( name="CommonSeq",sequenceName="common_seq", allocationSize=0)
    @Column(name = "SYS_USER_ID")
    private BigDecimal sysUserId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "LOGIN")
    private String login;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "PASSWORD")
    private String password;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "FIRSTNAME")
    private String firstname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "LASTNAME")
    private String lastname;
    @Column(name = "AGE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date age;
    @Size(max = 20)
    @Column(name = "CITY")
    private String city;
    @Size(max = 100)
    @Column(name = "INFO")
    private String info;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "E_MAIL")
    private String eMail;
    @Size(max = 40)
    @Column(name = "CONTACT_INFORMATION")
    private String contactInformation;
    @Size(max = 40)
    @Column(name = "LINK_ON_SOURCE")
    private String linkOnSource;
    @Size(max = 100)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Set<Tournament> tournamentSet;
    @OneToMany(mappedBy = "owner")
    private Set<League> leagueSet;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Set<Player> playerSet;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Set<Game> gameSet;
    @JoinColumn(name = "SYS_GROUP_ID", referencedColumnName = "SYS_GROUP_ID")
    @ManyToOne
    private SysGroup sysGroupId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Set<Team> teamSet;

    public SysUser() {
         
    }

    public SysUser(BigDecimal sysUserId) {
        super(SysUser.class);
        this.sysUserId = sysUserId;
    }

    public SysUser(BigDecimal sysUserId, String login, String password, String firstname, String lastname, String eMail) {
        super(SysUser.class);
        this.sysUserId = sysUserId;
        this.login = login;
        this.password = password;
        this.firstname = firstname;
        this.lastname = lastname;
        this.eMail = eMail;
    }

    public BigDecimal getSysUserId() {
        return sysUserId;
    }

    public void setSysUserId(BigDecimal sysUserId) {
        this.sysUserId = sysUserId;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public Date getAge() {
        return age;
    }

    public void setAge(Date age) {
        this.age = age;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getEMail() {
        return eMail;
    }

    public void setEMail(String eMail) {
        this.eMail = eMail;
    }

    public String getContactInformation() {
        return contactInformation;
    }

    public void setContactInformation(String contactInformation) {
        this.contactInformation = contactInformation;
    }

    public String getLinkOnSource() {
        return linkOnSource;
    }

    public void setLinkOnSource(String linkOnSource) {
        this.linkOnSource = linkOnSource;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public Set<Tournament> getTournamentSet() {
        return tournamentSet;
    }

    public void setTournamentSet(Set<Tournament> tournamentSet) {
        this.tournamentSet = tournamentSet;
    }

    @XmlTransient
    public Set<League> getLeagueSet() {
        return leagueSet;
    }

    public void setLeagueSet(Set<League> leagueSet) {
        this.leagueSet = leagueSet;
    }

    @XmlTransient
    public Set<Player> getPlayerSet() {
        return playerSet;
    }

    public void setPlayerSet(Set<Player> playerSet) {
        this.playerSet = playerSet;
    }

    @XmlTransient
    public Set<Game> getGameSet() {
        return gameSet;
    }

    public void setGameSet(Set<Game> gameSet) {
        this.gameSet = gameSet;
    }

    public SysGroup getSysGroupId() {
        return sysGroupId;
    }

    public void setSysGroupId(SysGroup sysGroupId) {
        this.sysGroupId = sysGroupId;
    }

    @XmlTransient
    public Set<Team> getTeamSet() {
        return teamSet;
    }

    public void setTeamSet(Set<Team> teamSet) {
        this.teamSet = teamSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sysUserId != null ? sysUserId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SysUser)) {
            return false;
        }
        SysUser other = (SysUser) object;
        if ((this.sysUserId == null && other.sysUserId != null) || (this.sysUserId != null && !this.sysUserId.equals(other.sysUserId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.SysUser[ sysUserId=" + sysUserId + " ]";
    }
    
}
